package com.lin.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lin.blog.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 通过用户名查询用户信息
     * @param username
     * @return
     */
    @Select("select id, username, nickname, head_image, phone, sex, create_time,last_time,real_name, qq, email, intro FROM `user` where username = #{username}")
    public User getUserInfoByUserName(String username);


    /**
     * 通过username修改密码
     * @param username
     * @param password
     * @return
     */
    @Update("update `user` set password = #{password}  WHERE username = #{username}")
    public int updateUserPasswordByUserName(@Param("username") String username,@Param("password") String password);

    /**
     * 更新用户头像
     * @param username
     * @param headImageUrl
     * @return
     */
    @Update("update `user` set head_image = #{headImageUrl}  WHERE username = #{username}")
    public Integer updateUserHeadImageByUserName(@Param("username") String username, @Param("headImageUrl") String headImageUrl);
}
